import request from '@/utils/request'

// 文章列表
export function getArticlesListApi(page = 1, pagesize = 2) {
  return request({
    url: `/articles`,
    method: 'get',
    params: {
      page,
      pagesize
    }
  })
}

// 搜索
export function searchArticlesListApi(params) {
  return request({
    url: `/articles`,
    method: 'get',
    params
  })
}

// 文章添加
export function addArticlesListApi(data) {
  return request({
    url: `/articles`,
    method: 'post',
    data
  })
}

// 文章删除
export function delArticlesListApi(id) {
  return request({
    url: `/articles/${id}`,
    method: 'delete'
  })
}

// 文章编辑
export function editArticlesListApi(data) {
  return request({
    url: `/articles/${data.id}`,
    method: 'put',
    data
  })
}

// 文章详情
export function getArticlesListDeatilApi(id) {
  return request({
    url: `/articles/${id}`,
    method: 'get'
  })
}

// 文章详情状态
export function editArticlesListDeatilApi(id, state) {
  return request({
    url: `/articles/${id}/${state}`,
    method: 'post'
  })
}
